<?php

!defined('IN_NOVA') && exit('Access Denied!');

class Search {

	public function __construct() {}

	public function __destruct() {}

	public function start() {
		global $db,$theme,$cache,$request;


	}
}
/*
$_ENV['title'] = "搜索";

// 参数处理
$search_word = safe_str_filter( getGP('word','G') );
$search_type = safe_str_filter( getGP('type','G') );

if( !empty( $search_word ) ) {
	if( $search_type == 'tag' ) {
		if ( !isset( $_CACHE['tag'][$search_word] ) ) {
			$_ENV['page']['content'] = '<div style = "text-align:center;margin:10px;"><strong>没有搜索到任何内容！</strong></div>';
			template('page');
			exit;
		}
		$_ENV['title'] = $_CACHE['tag'][$search_word]['t_name'] . ' - 搜索';
	}else{
		$_ENV['title'] = $search_word . ' - 搜索';
	}
	search( $search_word, $search_type );
}else{
	main();
}

function main() {
	$temp = '<div id = "main_search"><form name="frm" action="search.php" method="get">';
	$temp .= '<table width="100%" cellspacing="0" cellpadding="0">';
	$temp .= '<tr><td colspan="2" align="center"><h3>搜索目标</h3></td></tr>';
	$temp .= '<tr>';
	$temp .= '<th width="50%">关键词：';
	$temp .= '<br /><input type="text" name="word" size="20" />';
	$temp .= '</th>';
	$temp .= '<th>搜索范围：';
	$temp .= '<br /><input type="radio" name="type" value="title" checked /> 标题 <input type="radio" name="type" value="tag" /> 标签 <input type="radio" name="type" value="content" /> 正文';
	$temp .= '</th></tr></table>';
	$temp .= '<div style="margin-bottom:25px;text-align:center;">';
	$temp .= '<input class="button" type="submit" name="submit" value="提 交" /> <input class="button" type="reset" value="重 置" /></div></form></div>';
	$_ENV['page']['content'] = $temp;
	template('page');
}

function search( $search_word, $search_type = 'title' ) {
	global $db,$_ENV,$_CACHE;
	//if CDate( DateDiff( "s", Session("PostDate"), Now() ) ) < CDate( Blogcomtimer ) Then
	//	Search_content = "<div style = ""text-align:center;margin:10px;""><strong>操作限制，请再等一会儿再进行搜索！</strong></div>"
	//	Exit function
	//End if
	if( $search_type == 'tag' ) {
		$sql = "SELECT id,title,type,address,category FROM `" . PREFIX_STR . "article` WHERE tag LIKE '%{*" . $search_word . "*}%' AND isdel=0 ORDER BY id DESC LIMIT 0,10";
	}elseif( $search_type == 'content' ) {
		if( user_is_login() ) {
			$sql = "SELECT id,title,type,address,category FROM " . PREFIX_STR . "article WHERE content LIKE '%" . $search_word . "%' AND isdel=0 ORDER BY id DESC LIMIT 0,10";
		}else{
			show_message( '只有注册用户才能搜索正文，请先注册或登录！', 'login.php' );
			exit;
		}
	}else{
		$sql = "SELECT id,title,type,address,category FROM " . PREFIX_STR . "article WHERE title LIKE '%" . $search_word . "%' AND isdel=0 ORDER BY id DESC LIMIT 0,10";
	}
	$search_arr = array();
	$search_arr = $db->fetch_all( $sql );
	if ( !count( $search_arr ) ) {
		$_ENV['page']['content'] = '<div style = "text-align:center;margin:10px;"><strong>没有搜索到任何内容！</strong></div>';
		template('page');
		exit;
	}

	if( $search_type == 'tag' ) {
		$temp = '<div id = "main_search"><h3>搜索结果</h3><br />搜索类型：标签<br />搜索关键字：' . $_CACHE['tag'][$search_word]['t_name'] . '<ol>';
	}elseif( $search_type == 'content' ) {
		$temp = '<div id = "main_search"><h3>搜索结果</h3><br />搜索类型：正文<br />搜索关键字：' . $search_word . '<ol>';
	}else{
		$temp = '<div id = "main_search"><h3>搜索结果</h3><br />搜索类型：标题<br />搜索关键字：' . $search_word . '<ol>';
	}
	foreach( $search_arr as $value ) {
		if( $value['type'] == '动态' ) {
			$temp .= '<li><a href = "' . BLOG_PATH . 'read.php?id=' . $value['id'] . '" target="_blank" >' . $value['title'] . '</a></li>';
		}elseif ( $value['type'] == '半静态' ) {
			$temp .= '<li><a href = "' . BLOG_PATH . 'article/' . $_CACHE['category'][$value['category']]['alias'] . '/' . $value['address'] . '.php" target="_blank" >' . $value['title'] . '</a></li>';
		}else{
			$temp .= '<li><a href = "' . BLOG_PATH . 'article/' . $_CACHE['category'][$value['category']]['alias'] . '/' . $value['address'] . '.html" target="_blank" >' . $value['title'] . '</a></li>';
		}
	}
	$temp .= '</ol></div>';
	// Session("PostDate") = Now()
	$_ENV['page']['content'] = $temp;
	template('page');
}*/
?>